<?php
/**
 * This file is part of Hyperf Mall.
 *
 * @link     https://gitee.com/scwlkj/hyperf_mall
 * @contact  hyperf_mall@163.com
 */

namespace App\JsonRpc;

use App\Repository\NotifyRepository;
use Hyperf\RpcServer\Annotation\RpcService;
use App\JsonRpc\Interfaces\NotifyServiceInterface;

/**
 * @RpcService(name="Config::NotifyService", protocol="jsonrpc", server="jsonrpc")
 */
class NotifyService extends BaseService implements NotifyServiceInterface
{
    public function init()
    {
        $this->repository = NotifyRepository::getInstance();
    }

    public function index(array $condition, array $field, int $page, int $size): array
    {
        if(isset($condition['title']) && !empty($condition['title'])){
            $condition[] = ['title','like', '%'. trim($condition['title']) . '%'];
            unset($condition['title']);
        }
        return parent::index($condition, $field, $page, $size); // TODO: Change the autogenerated stub
    }

    /**
     * Notes: app 首页 滚动公告
     * Author: Bruce.z
     * DateTime: 2022/6/14 10:00
     */
    public function appIndexList():array
    {
        return $this->repository->appIndexList();
    }
}
